#
#SConstruct
#

import os

current_dir = os.getcwd()

#list all the .c files
SRC = ['ide.c', 'pram.c']

#output file name
OUT = 'libide.so'

#list all archetectures to compile this library for
ARCH = ['x86_64-softmmu']

#Export variables
#Export('SRC', 'OUT')

#Base environment
baseEnv = Environment()
baseEnv.Append(CPPPATH = ['.','../../', '../../hw', '../../slirp', '../../fpu'])
baseEnv.Append(CCFLAGS = ' -MMD -MP')
#baseEnv.Append(LDFLAGS = ' -lm ')

#Debug Options
baseEnv.Append(CCFLAGS = ' -g -L '+current_dir)
#baseEnv.Append(CCDFLAGS = ' -lefence ')

baseEnv.Append(CPPDEFINES = ['NEED_CPU_H', '_GNU_SOURCE', ('_FILE_OFFSET_BITS',64), '_LARGEFILE_SOURCE'])

#Call the every arch specific SConstruct
for ar in ARCH:
  archDir = '../' + ar
  buildDir = 'build-' + ar
  buildLib = buildDir + '/' + OUT
  env = baseEnv.Copy()
  env.BuildDir(buildDir, '.')
  env.Append(CPPPATH = '%s' % archDir)
  if ar == 'x86_64-softmmu' or ar == 'i386-softmmu':
    env.Append(CPPPATH = '../../target-i386')
  env.Append(LINK = ' -lm')
  #env.Object(SRC)
  env.Command(archDir + "/libs/" + OUT, buildLib, Copy("$TARGET", "$SOURCE"))
  env.SharedLibrary(buildLib, SRC)
  #print env.Dump()
  Default(archDir + "/libs/" + OUT)

